<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.hz.model.User"%>
<%@page import="com.hz.util.ParamUtil"%>
<%@page import="com.hz.control.UserControl"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'index.jsp' starting page</title>
  </head>
  <%
         User cu =(User)session.getAttribute("user");
         String rootpwd=ParamUtil.getString(request,"rootpwd",null);
         String newpwd1 = ParamUtil.getString(request,"newpwd1",null);
         String newpwd2 = ParamUtil.getString(request,"newpwd2",null);
         if(rootpwd!=null&&rootpwd.equals(cu.getPassword())){
        	 if(newpwd1.equals(newpwd2)){
        	 if(UserControl.updatePassword(newpwd1,cu.getId())){
        		 %>
        		 <script>
        		 alert("修改密码成功");
        		 history.go(-1);
        		 </script>
        		 <%
        	 }else{
        		 %>
        		 <script>
        		 alert("修改密码失败");
        		 history.go(-1);
        		 </script>
        		 <%
        	 }}else{
        		 %>
        		 <script>
        		 alert("新密码不一致");
        		 history.go(-1);
        		 </script>
        		 <%
        	 }}else{
        		 %>
        		 <script>
        		 alert("原密码错误");
        		 history.go(-1);
        		 </script>
        		 <%
        	   
         }
  %>
  <body>
  
  </body>
</html>
